:root {
  /* 颜色变量 */
  --primary-color: #0078d4;
  --primary-hover: #106ebe;
  --bg-dark: #1e1e1e;
  --bg-darker: #252526;
  --bg-header: #2d2d2d;
  --border-color: #333;
  --border-active: #404040;
  --text-color: #d4d4d4;
  --text-muted: #888;
  --text-light: #999;
  --shadow: rgba(0, 0, 0, 0.2);

  /* 尺寸变量 */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 12px;
  --spacing-lg: 16px;
  --header-height: 40px;
  --border-radius: 4px;
  --border-radius-lg: 6px;

  font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  font-weight: 400;

  color-scheme: light dark;
  color: rgba(255, 255, 255, 0.87);
  background-color: #242424;

  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 基础重置 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

a {
  font-weight: 500;
  color: #646cff;
  text-decoration: inherit;
}
a:hover {
  color: #535bf2;
}

body {
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-width: 320px;
  min-height: 100vh;
  padding: var(--spacing-lg);
  background-color: var(--bg-dark);
}

h1 {
  font-size: 3.2em;
  line-height: 1.1;
}

button {
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0.6em 1.2em;
  font-size: 1em;
  font-weight: 500;
  font-family: inherit;
  background-color: #1a1a1a;
  cursor: pointer;
  transition: border-color 0.25s;
}
button:hover {
  border-color: #646cff;
}
button:focus,
button:focus-visible {
  outline: 4px auto -webkit-focus-ring-color;
}

.card {
  padding: 2em;
}

#app {
  display: flex;
  height: 100vh;
  width: 100vw;
  margin: 0;
  padding: 0;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* 布局容器 */
.container {
  display: flex;
  width: 100%;
  height: calc(100vh - var(--spacing-lg) * 2);
  background-color: var(--bg-darker);
  color: var(--text-color);
  position: relative;
  border-radius: var(--border-radius-lg);
  box-shadow: 0 4px 12px var(--shadow);
  overflow: hidden;
}

/* 文件树样式 */
.file-tree {
  width: 300px;
  min-width: 200px;
  max-width: 400px;
  border-right: 1px solid var(--border-color);
  background-color: var(--bg-darker);
  overflow: auto;
  resize: horizontal;
}

.tree-item {
  padding: var(--spacing-sm) var(--spacing-md);
  cursor: pointer;
  color: var(--text-color);
}

.tree-children {
  margin-left: var(--spacing-lg);
  border-left: 1px dotted var(--border-active);
}

/* 添加文件树样式 */
.tree-content {
  padding: var(--spacing-sm);
  overflow-y: auto;
  height: calc(100% - 40px);
}

/* 更新文件树样式 */
.tree-item-container {
  margin: 2px 0;
}

.tree-node {
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 4px;
  transition: background-color 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.node-icon {
  width: 20px;
  text-align: center;
}

.node-name {
  flex: 1;
}

.tree-children {
  margin-left: 20px;
  display: none;
  border-left: 1px dotted #404040;
}

.tree-children-open {
  display: block;
}

.tree-node:hover {
  background-color: #383838;
}

/* 编辑器样式 */
.editor {
  flex: 1;
  background-color: var(--bg-dark);
  min-width: 300px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.code-editor {
  flex: 1;
  width: 100%;
  overflow: hidden;
}

/* 聊天区域样式 */
.chat {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: auto;
  background-color: var(--bg-darker);
  border-radius: var(--border-radius-lg);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-lg);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.chat-input {
  padding: var(--spacing-md) var(--spacing-lg);
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: var(--spacing-md);
  align-items: flex-end;
  background-color: var(--bg-header);
}

.chat-input textarea {
  flex: 1;
  height: 50px;
  background-color: var(--bg-darker);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  padding: var(--spacing-md);
  resize: none;
  border-radius: var(--border-radius-lg);
  transition: all 0.3s ease;
  font-size: 0.95em;
  line-height: 1.4;
}

.chat-input textarea:focus {
  border-color: var(--primary-color);
  outline: none;
  box-shadow: 0 0 0 2px rgba(0, 120, 212, 0.1);
}

.chat-input button {
  width: 80px;
  padding: var(--spacing-sm) var(--spacing-md);
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: var(--border-radius-lg);
  cursor: pointer;
  transition: all 0.2s ease;
  height: 38px;
  font-weight: 500;
}

.chat-input button:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
}

.chat-input button:active {
  transform: translateY(0);
}

/* 消息样式 */
.message {
  border-radius: var(--border-radius-lg);
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  min-height: min-content;
  margin: var(--spacing-xs) var(--spacing-lg);
  max-width: 85%;
}

.message:hover {
  transform: translateY(-1px);
}

.message.user,
.message.assistant {
  position: relative;
  box-shadow: 0 2px 8px var(--shadow);
  padding: var(--spacing-md);
}

.message.user {
  background-color: var(--bg-header);
  margin-left: auto;
  border-top-right-radius: 4px;
}

.message.assistant {
  background-color: var(--border-color);
  margin-right: auto;
  border-top-left-radius: 4px;
}

/* 消息内容 */
.message .content,
.message .reasoning {
  padding: var(--spacing-md) var(--spacing-lg);
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: break-word;
  font-size: 0.92em;
}

.message .reasoning {
  background-color: var(--bg-header);
  color: var(--text-light);
  border-radius: var(--border-radius);
  margin-bottom: var(--spacing-sm);
  min-height: 44px;
  display: flex;
  align-items: stretch;
  font-family: monospace;
}

.message .reasoning::before {
  content: "💡";
  position: absolute;
  left: var(--spacing-xs);
  top: var(--spacing-xs);
  font-size: 14px;
  line-height: 1;
  z-index: 2;
  pointer-events: none;
  opacity: 0.8;
}

/* Content Renderer */
.content-renderer {
  width: 100%;
  height: auto;
  min-height: min-content;
  position: relative;
  z-index: 1;
  flex: 1;
  display: block;
  padding-left: var(--spacing-xs);
}

/* 通用header样式 */
.tree-header,
.editor-header,
.chat-header {
  padding: 8px 16px;
  font-size: 1rem;
  font-weight: 500;
  background-color: #2d2d2d;
  border-bottom: 1px solid #404040;
  height: 40px;
  display: flex;
  align-items: center;
  user-select: none;
}

/* 滚动条样式 */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-header);
  border-radius: var(--border-radius);
}

::-webkit-scrollbar-thumb {
  background: #666;
  border-radius: var(--border-radius);
}

/* 响应式布局 */
@media (max-width: 1200px) {
  .container {
    min-width: 800px;
  }
  .file-tree {
    width: 250px;
    min-width: 150px;
  }
  .chat {
    width: 350px;
    min-width: 250px;
  }
}

@media (max-width: 900px) {
  .container {
    min-width: 600px;
  }
  .file-tree {
    width: 200px;
    min-width: 150px;
  }
  .chat {
    width: 300px;
    min-width: 200px;
  }
}

@media (prefers-color-scheme: light) {
  :root {
    color: #213547;
    background-color: #ffffff;
  }
  a:hover {
    color: #747bff;
  }
  button {
    background-color: #f9f9f9;
  }
}
